//=======================================================================
// The Siege static functions, HUD is built here
//=======================================================================
class TFStaticFunctions extends Object;

var const color Gold, Blue, Green, Orange, Red;
var LinearColor Black;

//Scoreboard
static simulated function string GetExtraRightMisc (UTPlayerReplicationInfo PRI, int Deaths, int Score, optional bool bIncludeDeaths=true)
{
    local int TotalSeconds, PPH;

    TotalSeconds = PRI.WorldInfo.GRI.ElapsedTime - PRI.StartTime;
    PPH = int(float(Score) / (float(TotalSeconds+1)/float(3600)));
    if (TFPRI(PRI).UsedCredits != 1)
    {
        if (bIncludeDeaths)
        {
            return "Deaths "$Deaths$"   "$"PPH "$PPH$"   "$"Loadout Value "$TFPRI(PRI).UsedCredits;
        }
        else
        {
            return "PPH "$PPH$"   "$"Loadout Value "$TFPRI(PRI).UsedCredits;
        }
    }
    else
    {
        if (bIncludeDeaths)
        {
            return "Deaths "$Deaths$"   "$"PPH "$PPH;
        }
        else
        {
            return "PPH "$PPH;
        }
    }
}

//Scoreboard
static simulated function string GetExtraRightName (UTPlayerReplicationInfo PRI)
{
    if (TFPRI(PRI).UsedCredits != 1)
    {
        return " - "$TFPRI(PRI).UsedCredits;
    }
    else
    {
        return "";
    }
}

//HUD
static simulated function DrawTile (UTHUD H, String Style, float X, float Y, float Wi, float He)
{
    //Simulate a virtual 1024*768 screen
    X = X * H.ResolutionScaleX;
    Y = Y * H.ResolutionScale;
    H.Canvas.SetPos(X, Y);
    H.Canvas.DrawColorizedTile(H.AltHudTexture, Wi * H.ResolutionScale, He * H.ResolutionScale, 489, 395,183, 44, H.TeamHudColor);
}

//HUD
static simulated function DrawText (UTHUD H, float X, float Y, string Text, optional string Font="large")
{
    if (H == None || H.Canvas == None) return;

  // Simulate a virtual 1024*768 screen
    X = X * H.ResolutionScaleX;
    Y = Y * H.ResolutionScale;

    if (Font == "tiny")
    {
        H.Canvas.Font = class'Engine'.static.GetTinyFont();
    }
    else if (Font == "small")
    {
        H.Canvas.Font = class'Engine'.static.GetSmallFont();
    }
    else if (Font == "medium")
    {
        H.Canvas.Font = class'Engine'.static.GetMediumFont();
    }
    else if (Font == "large")
    {
        H.Canvas.Font = class'Engine'.static.GetLargeFont();
    }

    if (Font == "tiny" || Font == "small" || Font == "medium") H.Canvas.SetPos (X+1, Y+1); else H.Canvas.SetPos (X+2, Y+2);
    H.Canvas.SetPos (X, Y);
    H.Canvas.DrawTextClipped (Text, false);
}

//HUD
static simulated function TFEnhanceHUD (TFTeamHUD H)
{
    local float YCursor;
    local vector2d POS;

    YCursor = 0;

    H.Canvas.SetPos(POS.X * H.ResolutionScale,POS.Y * H.ResolutionScale);
	H.Canvas.DrawColorizedTile(H.AltHudTexture, H.HealthBGCoords.UL * 2 * H.ResolutionScale, H.HealthBGCoords.VL/2.8 * H.ResolutionScale, H.HealthBGCoords.U, H.HealthBGCoords.V, H.HealthBGCoords.UL, H.HealthBGCoords.VL, default.Black);
    H.Canvas.SetPos(POS.X * H.ResolutionScale,POS.Y + 20 * H.ResolutionScale);
    H.Canvas.DrawColorizedTile(H.AltHudTexture, H.HealthBGCoords.UL * 2 * H.ResolutionScale, H.HealthBGCoords.VL/2.8 * H.ResolutionScale, H.HealthBGCoords.U, H.HealthBGCoords.V, H.HealthBGCoords.UL, H.HealthBGCoords.VL, default.Black);
    H.Canvas.SetPos(POS.X * H.ResolutionScale,POS.Y + 40  * H.ResolutionScale);
    H.Canvas.DrawColorizedTile(H.AltHudTexture, H.HealthBGCoords.UL * 2 * H.ResolutionScale, H.HealthBGCoords.VL/2.8 * H.ResolutionScale, H.HealthBGCoords.U, H.HealthBGCoords.V, H.HealthBGCoords.UL, H.HealthBGCoords.VL, default.Black);
    H.Canvas.SetPos(POS.X * H.ResolutionScale,POS.Y + 60  * H.ResolutionScale);
    H.Canvas.DrawColorizedTile(H.AltHudTexture, H.HealthBGCoords.UL * 2 * H.ResolutionScale, H.HealthBGCoords.VL/2.8 * H.ResolutionScale, H.HealthBGCoords.U, H.HealthBGCoords.V, H.HealthBGCoords.UL, H.HealthBGCoords.VL, default.Black);
    H.Canvas.SetPos(POS.X * H.ResolutionScale,POS.Y + 80  * H.ResolutionScale);
    H.Canvas.DrawColorizedTile(H.AltHudTexture, H.HealthBGCoords.UL * 2 * H.ResolutionScale, H.HealthBGCoords.VL/2.8 * H.ResolutionScale, H.HealthBGCoords.U, H.HealthBGCoords.V, H.HealthBGCoords.UL, H.HealthBGCoords.VL, default.Black);

    if (H.PlayerOwner.PlayerReplicationInfo.Team.TeamIndex == 0)
    {
        H.Canvas.DrawColor = default.Red;
        DrawText (H, 10, YCursor, "Control Limit:" $ int(TFGRI(H.UTGRI).MaxControl[0]) , "medium"); YCursor += 20;
        H.Canvas.DrawColor = default.Gold;
        DrawText (H, 10, YCursor, "Used Control:" $ int(TFGRI(H.UTGRI).Control[0]) , "medium"); YCursor += 20;
    }
    else
    {
        H.Canvas.DrawColor = default.Red;
        DrawText (H, 10, YCursor, "Control Limit:" $ int(TFGRI(H.UTGRI).MaxControl[1]) , "medium"); YCursor += 20;
        H.Canvas.DrawColor = default.Gold;
        DrawText (H, 10, YCursor, "Used Control:" $ int(TFGRI(H.UTGRI).Control[1]) , "medium"); YCursor += 20;
    }



    H.Canvas.DrawColor = default.Blue;
    DrawText (H, 10, YCursor, "RES:" $ int(TFPRI(H.PlayerOwner.PlayerReplicationInfo).RES) , "medium"); YCursor += 20;
    H.Canvas.DrawColor = default.Green;
    DrawText (H, 10, YCursor, "Credits:" $ int(TFPRI(H.PlayerOwner.PlayerReplicationInfo).Credits) , "medium"); YCursor += 20;
    H.Canvas.DrawColor = default.Orange;
    DrawText (H, 10, YCursor, "Loadout Value:" $ TFPRI(H.PlayerOwner.PlayerReplicationInfo).UsedCredits , "medium"); YCursor += 20;
}

///////////////////////////////////////////////////////////////Use later for sending players messages/////////////////////////////////////
/*static function Message2Pawn (Pawn P, string Type, string Msg)
{
    if (P == None || TFPlayerController(P.Controller) == None)
        return;

    TFPlayerController(P.Controller).Message2PC (Type, Msg);
}

static function Message2PC (PlayerController PC, string Type, string Msg)
{
    if (TFPlayerController (PC) == None)
    return;

    if (Type == "DefendCore")
    {
        PC.ClientMessage (Msg);
    }
}*/

defaultproperties
{
  Black=(B=0,G=0,R=0,A=1)
  Gold=(B=11,G=183,R=255,A=200)
  Blue=(B=213,G=90,R=0,A=200)
  Green=(B=0,G=142,R=37,A=200)
  Orange=(B=0,G=131,R=199,A=200)
  Red=(B=2,G=2,R=152,A=200)
  Name="TFStaticFunctions"
}